<%@ page import="com.lihuanyu.upcOA.conn.databaseUtil" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.util.Calendar" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
  int tid = 0;
  if(session.getAttribute("tid") != null) {
    tid = Integer.parseInt(session.getAttribute("tid").toString());
  }
  Calendar a= Calendar.getInstance();
  int year=a.get(Calendar.YEAR);
  //System.out.print(year);
  request.setCharacterEncoding("utf-8");
  String teaname = request.getParameter("teaname") == null ? "" : new String(request.getParameter("teaname"));
  String bookname= request.getParameter("artiname") == null ? "" : new String(request.getParameter("artiname"));
  String area = request.getParameter("area") == null ? "" : new String(request.getParameter("area"));
  String dorm = request.getParameter("dorm") == null ? "" : new String(request.getParameter("dorm"));
  databaseUtil db = new databaseUtil();
  String sql = "INSERT INTO `book`(`teaname`, `bookname`, `category`, `masofdr`, `year`, `tid`) " +
          "VALUES ('"+teaname+"','"+bookname+"','"+area+"','"+dorm+"',"+year+","+tid+")";
  System.out.print(sql);
  db.executeUpdate(sql);
%>
<tr>
  <div class="col-md-1">
    <td>老师</td>
  </div>
  <div class="col-md-1">
    <td>论文题目</td>
  </div>
  <div class="col-md-1">
    <td>所属分区</td>
  </div>
  <div class="col-md-1">
    <td>博士/硕士论文</td>
  </div>
</tr>
<form method="post" action="#" name="add_form">
  <tr style="display: none" class="add_row">
    <div class="col-md-1">
      <td><input type="text" name="teacher_name" id="teaname4"></td>
    </div>
    <div class="col-md-1">
      <td><input type="text" name="title" id="title"></td>
    </div>
    <div class="col-md-1">
      <td><input type="text" name="area" id="area"></td>
    </div>
    <div class="col-md-1">
      <td>
        <select id="dart">
          <option value="boshilunwen">博士论文</option>
          <option value="shuoshilunwen">硕士论文</option>
        </select>
      </td>
    </div>
  </tr>
</form>
<%
  sql="select * from book where tid="+tid;
  System.out.print(sql);
  db.executeQuery(sql);
  ResultSet rs = db.getRs();
  while (rs.next()){
    String teachername= rs.getString(2);
    String tbookname =    rs.getString(3);
    String category  =      rs.getString(4);
    String tdorm =     rs.getString(5);
%>
<tr class="second">
  <div class="col-md-1">
    <td><%=teachername%></td>
  </div>
  <div class="col-md-1">
    <td><%=tbookname%></td>
  </div>
  <div class="col-md-1">
    <td><%=category%></td>
  </div>
  <div class="col-md-1">
    <td><%=tdorm%></td>
  </div>
</tr>
<%
  }
  db.sqlclose();
%>

